package adkr

import "ebbflow/pkg/crypto"

// ... (All other structs are unchanged, only DealerContent is modified)

// DealerContent is the structure of the original large message created by the dealer.
type DealerContent struct {
	ScriptA   []string    `json:"script_a"`   // FIXED: Type changed from [][]byte to []string
	ScriptRA  []string    `json:"script_r_a"` // FIXED: Type changed from [][]byte to []string
	CommitsA  []crypto.G1 `json:"commits_a"`
	ScriptB   []string    `json:"script_b"`   // FIXED: Type changed from [][]byte to []string
	ScriptRB  []string    `json:"script_r_b"` // FIXED: Type changed from [][]byte to []string
	CommitsB  []crypto.G1 `json:"commits_b"`
	DealerPID int         `json:"dealer_pid"`
    ProofA    []string    `json:"proof_a"`    // per-recipient ZK proof for ScriptA
    ProofB    []string    `json:"proof_b"`    // per-recipient ZK proof for ScriptB
}

// For clarity, here is the full file:
type BroadcastTag string

const (
	ADKR_ACSS     = "ADKR_ACSS"
	ADKG_RBC      = "ADKG_RBC"
	ADKG_RANDEX   = "ADKG_RANDEX"
	ADKG_KEY      = "ADKG_KEY"
	ADKR_COMPLAIN = "ADKR_COMPLAIN"
	ADKR_ABA      = "ADKR_ABA"
	ADKG_COIN     = "ADKG_COIN"
	ADKR_MVBA     = "ADKR_MVBA"
    ADKR_SPBC     = "ADKR_SPBC"
)

type Message struct {
	Tag     BroadcastTag `json:"tag"`
	Round   int          `json:"round"`
	Sender  int          `json:"-"`
	To      int          `json:"to"`
	Payload []byte       `json:"payload"`
}
type PoK struct {
	C crypto.ZR `json:"c"`
	Z crypto.ZR `json:"z"`
}
type RandexPayload struct {
	S crypto.ZR `json:"s"`
	R crypto.ZR `json:"r"`
}
type KeyPayload struct {
	Sgz  crypto.G1 `json:"sgz"`
	ShzS crypto.G1 `json:"shz_s"`
	Pi   PoK       `json:"pi"`
	PiS  PoK       `json:"pi_s"`
}
type MVBAPayload struct {
	SubTag     string `json:"sub_tag"`
	SubPayload []byte `json:"sub_payload"`
}
type ACSSTag string

const (
	ValTag   ACSSTag = "VAL"
	EchoTag  ACSSTag = "ECHO"
	ReadyTag ACSSTag = "READY"
)

type ACSSMessage struct {
	Tag     ACSSTag `json:"tag"`
	Payload []byte  `json:"payload"`
}
type ValPayload struct {
	RootHash []byte   `json:"root_hash"`
	Branch   [][]byte `json:"branch"`
	Stripe   []byte   `json:"stripe"`
    TotalLen int      `json:"total_len,omitempty"`
}
type EchoPayload = ValPayload
type ReadyPayload struct {
	RootHash []byte `json:"root_hash"`
}
type MVBATag string

const (
	MVBA_CoinTag    MVBATag = "VABA_COIN"
	MVBA_ABACoinTag MVBATag = "VABA_ABA_COIN"
	MVBA_RBCTag     MVBATag = "VABA_RBC"
	MVBA_ABATag     MVBATag = "VABA_ABA"
)

type MVBAMessage struct {
	Tag     MVBATag `json:"tag"`
	Round   int     `json:"round"`
	Payload []byte  `json:"payload"`
}
type RBCTag string

const (
	RBCValTag   RBCTag = "VAL"
	RBCEchoTag  RBCTag = "ECHO"
	RBCReadyTag RBCTag = "READY"
)

type RBCMessage struct {
	Tag     RBCTag `json:"tag"`
	Payload []byte `json:"payload"`
}
type RBCValPayload = ValPayload
type RBCReadyPayload = ReadyPayload
type ABATag string

const (
	BValTag   ABATag = "BVAL"
	AuxTag    ABATag = "AUX"
	FinishTag ABATag = "FINISH"
)

type ABAMessage struct {
	Tag     ABATag `json:"tag"`
	Round   int    `json:"round"`
	Payload []byte `json:"payload"`
}
type BValPayload struct {
	Est  int `json:"est"`
	MajR int `json:"maj_r"`
    Sup  int `json:"sup"` // supporters count (optional)
    SupSet []int `json:"sup_set,omitempty"` // optional supporter set evidence
}
type AuxPayload struct {
	V int `json:"v"`
	A int `json:"a"`
    Sup int `json:"sup"` // supporters count (optional)
    SupSet []int `json:"sup_set,omitempty"` // optional supporter set evidence
}
type FinishPayload struct {
	V int `json:"v"`
    Sup int `json:"sup"` // supporters count (optional)
    SupSet []int `json:"sup_set,omitempty"` // optional supporter set evidence
}
// coin payload types are defined in thresholdcoin.go
